package com.hunt.model.app;


import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;
import java.util.List;

//基本数据详情
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class FinancialDataInfo {

    private String ths_stock_code_stock;//股票代码 string
    private String ths_thscode_stock;//同花顺股票代码 string
    private String ths_stock_short_name_stock;//股票简称 string
    private String ths_phonetic_short_name_stock;//股票名称首字母
    private String ths_province_stock;//省份 string
    private String ths_ipo_date_stock;//首发上市日期 date
    private String ths_the_sw_industry_stock;//所属申万行业 string
    private String ths_total_shares_stock;//总股本 double
    private String ths_total_float_shares_stock;//流通股合计 double
    private String ths_mv_by_total_shares_stock;//总市值(总股本算) double
    private String ths_current_mv_stock;//流通市值 double
    private String ths_eps_basic_stock;//每股收益EPS(基本) double
    private String ths_roe_dlt_publish_stock;//净资产收益率ROE(摊薄,公布值) double
    private String ths_roe_wgt_publish_stock;//净资产收益率ROE(加权,公布值) double
    private String ths_pe_stock;//PE静态市盈率(加权,公布值) double
    private String ths_pe_mrq_stock;//PE滚动市盈率 double
    private String ths_pe_ttm_stock;//PE市盈率TTM double
    private String ths_pb_latest_stock;//"PB市净率(最新)" double
    private int ths_is_shutdown = 1;//是否停盘 0:是   1:不是
    private Date update_time;

    public FinancialDataInfo(JSONObject jsonObject, List<String> shutdownCodeList){
        JSONObject table = jsonObject.getJSONObject("table");
        String upperCode = table.getJSONArray("ths_thscode_stock").getString(0);
        if (shutdownCodeList.contains(upperCode)){
            this.ths_is_shutdown = 0;
        }
        this.ths_stock_code_stock = table.getJSONArray("ths_stock_code_stock").getString(0);
        this.ths_thscode_stock = upperCode.toLowerCase();
        this.ths_stock_short_name_stock = table.getJSONArray("ths_stock_short_name_stock").getString(0);
        this.ths_phonetic_short_name_stock = table.getJSONArray("ths_phonetic_short_name_stock").getString(0);
        this.ths_province_stock = table.getJSONArray("ths_province_stock").getString(0);
        this.ths_ipo_date_stock = table.getJSONArray("ths_ipo_date_stock").getString(0);
        this.ths_the_sw_industry_stock = table.getJSONArray("ths_the_sw_industry_stock").getString(0);
        this.ths_total_shares_stock = table.getJSONArray("ths_total_shares_stock").getString(0);
        this.ths_total_float_shares_stock = table.getJSONArray("ths_total_float_shares_stock").getString(0);
        this.ths_mv_by_total_shares_stock = table.getJSONArray("ths_mv_by_total_shares_stock").getString(0);
        this.ths_current_mv_stock = table.getJSONArray("ths_current_mv_stock").getString(0);
        this.ths_eps_basic_stock = table.getJSONArray("ths_eps_basic_stock").getString(0);
        this.ths_roe_dlt_publish_stock = table.getJSONArray("ths_roe_dlt_publish_stock").getString(0);
        this.ths_roe_wgt_publish_stock = table.getJSONArray("ths_roe_wgt_publish_stock").getString(0);
        this.ths_pe_stock = table.getJSONArray("ths_pe_stock").getString(0);
        this.ths_pe_mrq_stock = table.getJSONArray("ths_pe_mrq_stock").getString(0);
        this.ths_pe_ttm_stock = table.getJSONArray("ths_pe_ttm_stock").getString(0);
        this.ths_pb_latest_stock = table.getJSONArray("ths_pb_latest_stock").getString(0);
        this.update_time = new Date();
    }
}
